home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Development / 3DMF parser / 0.9 version / MFINT64.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-24  |  1.8 KB  |  58 lines  |  [TEXT/MPS ]

  1. #ifndef MF3DINT64_H
  2. #define    MF3DINT64_H
  3. /*==============================================================================
  4.  *
  5.  *    File:        MFINT64.H
  6.  *
  7.  *    Function:    If the compiler/platform does not handle 64-bit numbers,
  8.  *                we will need some helper math routines.
  9.  *
  10.  *    Author(s):    Rick Wong (RWW)
  11.  *
  12.  *    Copyright:    (c) 1995 by Apple Computer, Inc., all rights reserved.
  13.  *
  14.  *    Change History (most recent first):
  15.  *        Fabio    Changed file name to 8 characters
  16.  *        F2F_RWW    File created.
  17.  *==============================================================================
  18.  */
  19. #if defined(__COMPILING_ON_MACINTOSH__)
  20. #pragma once
  21. #endif
  22.  
  23. #include "MFSYSTYP.H"
  24. #include "MFASSERT.H"
  25.  
  26. #define    Int32ToInt64(lnum,int64)    {    if ((lnum) >= 0)                    \
  27.                                             (int64).hi = 0;                    \
  28.                                         else                                \
  29.                                             (int64).hi = -1;                \
  30.                                         (int64).lo = (lnum);                \
  31.                                     }
  32.  
  33. #define CompareInt64(i1, i2)                                                \
  34.                         (((i1).hi - (i2).hi) != 0 ?                            \
  35.                             (((MF3DInt32)(i1).hi) - ((MF3DInt32)(i2).hi)) :    \
  36.                             (((MF3DInt32)(i1).lo) - ((MF3DInt32)(i2).lo))    \
  37.                         )
  38.  
  39. #define    AssignInt64(idst, isrc)        (idst).hi = (isrc).hi,                    \
  40.                                     (idst).lo = (isrc).lo;
  41.  
  42. #define    SetInt64ToZero(idst)        (idst).hi = 0, (idst).lo = 0;
  43.  
  44. /* This macro should only be used if appropriate range checks are made        */
  45. #define    Uns64ToUns32(int64,lnum)    MFASSERT((int64).hi == 0), (lnum) = (int64).lo
  46.  
  47. /* Calculate i1 - i2 (assumes that i1 >= i2), returning result in an Uns32    */
  48. /* Also assumes that result will fit into an Uns32.                            */
  49. #define    SubtractUns64(i1, i2)                                                \
  50.                     (    MFASSERT((i1).hi == (i2).hi ||                    \
  51.                         ((i1).hi == ((i2).hi + 1) && (i2).lo > (i1).lo)),    \
  52.                         ( ((i1).hi - (i2).hi) != 0 ?                        \
  53.                         ((i1).lo + (MF3DUns32)(-(MF3DInt32)((i2).lo))) :    \
  54.                         ((i1).lo - (i2).lo) )                                \
  55.                     )
  56.  
  57. #endif
  58.